package cz.muni.fi.cassandra.Playorm.dao;

import java.util.List;

import com.alvazan.orm.api.base.NoSqlEntityManager;

import cz.muni.fi.cassandra.Playorm.entities.UserPlayorm;

public class UserPlayormDaoImpl implements UserPlayormDao {

	private NoSqlEntityManager mgr;

	public UserPlayormDaoImpl(NoSqlEntityManager em) {
		this.mgr = em;
	}

	public void createUser(UserPlayorm user) {
		if (user == null) {
			throw new IllegalArgumentException("user is null");
		}

		mgr.put(user);
		mgr.flush();
	}

	public UserPlayorm getUserById(String id) {
		if (id == null) {
			throw new IllegalArgumentException("id is null");
		}

		UserPlayorm result = mgr.find(UserPlayorm.class, id);
		mgr.flush();
		return result;
	}

	public void deleteUser(UserPlayorm user) {
		if (user == null) {
			throw new IllegalArgumentException("user doesnt exist");
		}

		mgr.remove(user);
		mgr.flush();

	}

	public List<UserPlayorm> findAllUsers() {
		//TODO
		return null;
	}

}
